package com.tanglinkai.mall.mapper;

import com.tanglinkai.mall.entity.po.Supplier;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SupplierMapper {
    /**
     * 添加供应商
     * @param supplier
     */
    @Insert("INSERT INTO wn_supplier (name, contact, phoneNumber, status) VALUES (#{name}, #{contact}, #{phoneNumber}, #{status})")
    void addSupplier(Supplier supplier);

    /**
     * 查询所有供应商
     * @return
     */
    @Select("SELECT * FROM wn_supplier")
    List<Supplier> getAllSuppliers();

    /**
     * 根据ID删除供应商
     * @param id
     */
    @Delete("DELETE FROM wn_supplier WHERE id = #{id}")
    void deleteSupplierById(Integer id);

    /**
     * 根据ID查询供应商
     * @param id
     * @return
     */
    @Select("SELECT id, name, contact, phoneNumber, status FROM wn_supplier WHERE id = #{id}")
    Supplier getSupplierById(Integer id);
}
